package com.jdzy.student.controller;

import com.jdzy.model.common.vos.Result;
import com.jdzy.model.student.dtos.StudentDto;
import com.jdzy.student.service.StudentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("api/student")
@Api(value = "学生的controller类")
public class StudentController {
    @Autowired
    private StudentService studentService;

    /**
     * 根据stuId学号获取学生信息
     * @param stuId
     * @return
     */
    @GetMapping("getStudentByStuId/{stuId}")
    public Result getStudentByStuId(@PathVariable String stuId){
        return studentService.getStudentByStuId(stuId);
    }

    /**
     * 注册学生信息
     * @return
     */
    @PostMapping("saveStudent")
    public Result saveStudent(@RequestBody StudentDto studentDto){
        return studentService.saveStudent(studentDto);
    }

    /**
     * 根据学号修改信息
     * @param studentDto
     * @return
     */
    @PostMapping("updateStudentByStuId")
    public Result updateStudentByStuId(@RequestBody StudentDto studentDto){
        return studentService.updateStudentByStuId(studentDto);
    }


}
